﻿<wpfui:UiPage
    x:Class="LenovoLegionToolkit.WPF.Pages.PackagesPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="clr-namespace:LenovoLegionToolkit.WPF.Controls"
    xmlns:resources="clr-namespace:LenovoLegionToolkit.WPF.Resources"
    xmlns:utils="clr-namespace:LenovoLegionToolkit.WPF.Utils"
    xmlns:wpfui="http://schemas.lepo.co/wpfui/2022/xaml"
    Title="{x:Static resources:Resource.PackagesPage_Title}"
    FlowDirection="{x:Static utils:LocalizationHelper.Direction}">

    <Grid Margin="0,0,0,0">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Grid Grid.Row="0">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <TextBlock
                Grid.Row="0"
                Margin="0,24,0,24"
                FontSize="24"
                FontWeight="Medium"
                Text="{x:Static resources:Resource.PackagesPage_Title}" />

            <wpfui:CardControl
                Grid.Row="1"
                Margin="0,0,16,8"
                FocusVisualStyle="{DynamicResource DefaultControlFocusVisualStyle}">
                <wpfui:CardControl.Header>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="3*" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>

                        <Label
                            Grid.Row="0"
                            Grid.Column="0"
                            VerticalContentAlignment="Center"
                            Content="{x:Static resources:Resource.PackagesPage_MachineType}">
                            <Label.Foreground>
                                <SolidColorBrush Color="{DynamicResource TextFillColorPrimary}" />
                            </Label.Foreground>
                        </Label>
                        <Label
                            Grid.Row="1"
                            Grid.Column="0"
                            Margin="0,8,0,0"
                            VerticalContentAlignment="Center"
                            Content="{x:Static resources:Resource.PackagesPage_OperatingSystem}">
                            <Label.Foreground>
                                <SolidColorBrush Color="{DynamicResource TextFillColorPrimary}" />
                            </Label.Foreground>
                        </Label>
                        <Label
                            Grid.Row="2"
                            Grid.Column="0"
                            Margin="0,8,0,0"
                            VerticalContentAlignment="Center"
                            Content="{x:Static resources:Resource.PackagesPage_DownloadTo}">
                            <Label.Foreground>
                                <SolidColorBrush Color="{DynamicResource TextFillColorPrimary}" />
                            </Label.Foreground>
                        </Label>

                        <wpfui:TextBox
                            x:Name="_machineTypeTextBox"
                            Grid.Row="0"
                            Grid.Column="1"
                            Margin="8,0,0,0"
                            PlaceholderText="(eg. 82JQ)" />
                        <ComboBox
                            x:Name="_osComboBox"
                            Grid.Row="1"
                            Grid.Column="1"
                            Margin="8,8,0,0"
                            MaxDropDownHeight="Auto" />
                        <Grid
                            Grid.Row="2"
                            Grid.Column="1"
                            Margin="8,8,0,0">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>

                            <wpfui:TextBox
                                x:Name="_downloadToText"
                                Grid.Column="0"
                                TextChanged="DownloadToText_OnTextChanged" />

                            <wpfui:Button
                                Grid.Column="1"
                                Margin="4,0,0,0"
                                VerticalAlignment="Stretch"
                                Click="DownloadToButton_Click"
                                Icon="MoreHorizontal24" />

                            <wpfui:Button
                                Grid.Column="2"
                                Margin="4,0,0,-1"
                                VerticalAlignment="Stretch"
                                Click="OpenDownloadToButton_Click"
                                Icon="Open24" />

                        </Grid>

                        <StackPanel
                            Grid.Row="0"
                            Grid.RowSpan="3"
                            Grid.Column="3"
                            HorizontalAlignment="Right">

                            <TextBlock Margin="0,0,0,4" Text="{x:Static resources:Resource.PackagesPage_Source}" />
                            <RadioButton
                                x:Name="_sourcePrimaryRadio"
                                GroupName="source"
                                IsChecked="True">
                                <StackPanel>
                                    <TextBlock Text="{x:Static resources:Resource.PackagesPage_PrimarySource}" />
                                    <TextBlock
                                        FontSize="12"
                                        Foreground="{DynamicResource TextFillColorSecondaryBrush}"
                                        Text="{x:Static resources:Resource.PackagesPage_PrimarySource_Message}" />
                                </StackPanel>
                            </RadioButton>
                            <RadioButton x:Name="_sourceSecondaryRadio" GroupName="source">
                                <StackPanel>
                                    <TextBlock Text="{x:Static resources:Resource.PackagesPage_SecondarySource}" />
                                    <TextBlock
                                        FontSize="12"
                                        Foreground="{DynamicResource TextFillColorSecondaryBrush}"
                                        Text="{x:Static resources:Resource.PackagesPage_SecondarySource_Message}" />
                                </StackPanel>
                            </RadioButton>

                        </StackPanel>

                        <wpfui:Button
                            x:Name="_downloadPackagesButton"
                            Grid.Row="3"
                            Grid.Column="3"
                            HorizontalAlignment="Stretch"
                            VerticalAlignment="Bottom"
                            Appearance="Primary"
                            Click="DownloadPackagesButton_Click"
                            Content="{x:Static resources:Resource.Refresh}"
                            IsEnabled="false" />

                        <wpfui:Button
                            x:Name="_cancelDownloadPackagesButton"
                            Grid.Row="3"
                            Grid.Column="3"
                            HorizontalAlignment="Stretch"
                            VerticalAlignment="Bottom"
                            Appearance="Secondary"
                            Click="CancelDownloadPackagesButton_Click"
                            Content="{x:Static resources:Resource.Cancel}"
                            IsEnabled="false"
                            Visibility="Collapsed" />
                    </Grid>
                </wpfui:CardControl.Header>
            </wpfui:CardControl>

            <controls:LoadableControl
                x:Name="_loader"
                Grid.Row="2"
                IndicatorVerticalAlignment="Center"
                Visibility="Hidden">
                <wpfui:DynamicScrollViewer x:Name="_scrollViewer">

                    <StackPanel>

                        <wpfui:InfoBar
                            x:Name="_infoBar"
                            Title="{x:Static resources:Resource.PackagesPage_Disclaimer_Message}"
                            Margin="0,0,16,8"
                            IsClosable="True"
                            IsOpen="True" />

                        <Grid Margin="0,0,16,8">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="250" />
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>

                            <wpfui:TextBox
                                x:Name="_filterTextBox"
                                Grid.Column="0"
                                Icon="Search24"
                                PlaceholderEnabled="True"
                                PlaceholderText="{x:Static resources:Resource.Filter}"
                                TextChanged="FilterTextBox_TextChanged" />

                            <CheckBox
                                x:Name="_onlyShowUpdatesCheckBox"
                                Grid.Column="1"
                                Margin="16,0,0,0"
                                Checked="OnlyShowUpdatesCheckBox_OnChecked"
                                Content="{x:Static resources:Resource.PackagesPage_OnlyShowUpdates}"
                                Unchecked="OnlyShowUpdatesCheckBox_OnChecked" />

                            <ComboBox
                                x:Name="_sortingComboBox"
                                Grid.Column="3"
                                MaxDropDownHeight="Auto"
                                SelectedIndex="2"
                                SelectionChanged="SortingComboBox_SelectionChanged">
                                <ComboBoxItem Content="{x:Static resources:Resource.PackagesPage_Sort_Name}" />
                                <ComboBoxItem Content="{x:Static resources:Resource.PackagesPage_Sort_Category}" />
                                <ComboBoxItem Content="{x:Static resources:Resource.PackagesPage_Sort_Date}" />
                            </ComboBox>

                        </Grid>

                        <StackPanel x:Name="_packagesStackPanel" Margin="0,0,16,12" />

                    </StackPanel>

                </wpfui:DynamicScrollViewer>
            </controls:LoadableControl>

        </Grid>
    </Grid>
</wpfui:UiPage>
